import json

def print_instructions(jsonl_file_path, print_similiar=False):
    count = 0
    with open(jsonl_file_path, 'r', encoding='utf-8') as file:
        for line in file:
            try:
                data = json.loads(line)
                count += 1
                if print_similiar:
                    print(data["instruction"], data["most_similiar"])
                else:
                    print(data["instruction"])
            except json.JSONDecodeError:
                print(f"Error decoding JSON from line: {line}")
    return count


if __name__ == '__main__':
    jsonl_file_path = '../mydata/llama3_generations_seed01_1000/machine_generated_instructions.jsonl'
    count = print_instructions(jsonl_file_path)
    print(str(count)+" instructions displayed.")